package DataBase;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.mysql.jdbc.ResultSet;

public class CheckExistsEmployee {
	
	private String IDEmp;
	private String user;
	private int permission;
	
	
	

	public CheckExistsEmployee(String user)
	{
		this.IDEmp=user;
			
	}

	public void Check() 
	{
		
		SQLConnection sc=new SQLConnection();
		try {
			PreparedStatement ps1 = sc.getConnection().prepareStatement("SELECT name,permission FROM employee WHERE eid=? ;");
			ps1.setString(1, IDEmp);
			ResultSet rs=(ResultSet) ps1.executeQuery();	
			if (rs.next())
			{
				
			user=rs.getString(1);	
			permission=rs.getInt(2);
			}
			else
			{
				user="null";
				permission=-1;
			}
			rs.close();
			ps1.close();
			 sc.getConnection().close();
		} 
		
		catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	
	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getIDEmp() {
		return IDEmp;
	}

	public void setIDEmp(String iDEmp) {
		IDEmp = iDEmp;
	}

	public int getPermission() {
		return permission;
	}

	public void setPermission(int permission) {
		this.permission = permission;
	}
	
}
